package myThread;

public class MyThread extends Thread{

    // 带参构造方法
    public MyThread(String name) {
        super.setName(name);
    }

    @Override
    public void run() {
        // 此处的代码就是线程开启后要执行的代码
        for (int i = 0; i < 10; i++) {
            System.out.println("线程开启了" + i);
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
